package communicationMessages;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map.Entry;


import data.Forum;
import data.MemberDataBase;
import data.SubForum;
import database.DB;

public class ViewForumMessage extends Message {

	@Override
	public String getAnswer() {
		String userName = this.content.split(delimiter)[0];
		String ans = "subForumList"+delimiter+DB.getUserRoll(userName)+delimiter;
		long id = Thread.currentThread().getId();
		changeCurrentPath(-1, id);
		changeCurrentPathViewThread(-1, id);
		
    	ResultSet rs = DB.getSubForumList();

    	try {
			while(rs.next())
			{
				ans = ans+ rs.getString(DB.subForums.subForumId.ordinal()) +":" + rs.getString(DB.subForums.subForumTopic.ordinal()) + delimiter;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
    	

		//String ans = "subForumList"+delimiter+MemberDataBase.getUserRoll(userName)+delimiter;
		/*for(Entry<Integer,SubForum> indexandSubForum :Forum.getForum().get_subForumColection().entrySet()){
			ans+=indexandSubForum.getKey() +":" + indexandSubForum.getValue().get_topic() + delimiter;
		}
		*/
		return ans;
	}

}
